package leecodeHot100.hash;

import java.util.*;

public class AlphabeticGroup {
    public static void main(String[] args) {
        String[] strs = new String[]{"eat", "tea", "tan", "ate", "nat", "bat"};
        Map<String,List<String>> map = new HashMap<>();
        for (String str : strs) {
            char[] arr = str.toCharArray();
            Arrays.sort(arr);
            String key = new String(arr);
            List<String> list = map.getOrDefault(key,new ArrayList<>());
            list.add(str);
            map.put(key,list);
        }
        List<List<String>> re = new ArrayList();
        re.addAll(map.values());
        ArrayList<List<String>> lists = new ArrayList<>(map.values());
        System.out.println(lists);
    }
}
